<template>
  <div style="text-align: center;padding: 10px;">
    <j-space>
      <h2>{{ title }}</h2>
      <JButton style="margin-left: 50px;" type="info" @click="saveHelp">保存</JButton>
    </j-space>
  </div>
 <div style="width: 1000px;margin: 0 auto;">
   <div ref="divRef" style="height: calc(100vh - 85px);"/>
 </div>
</template>

<script setup>
// import {AiEditor} from "aieditor";
// import "aieditor/dist/style.css"
import tool from "@/utils/tool";
import {ref, onMounted,onUnmounted} from "vue";
import {useRoute} from "vue-router";
const route = useRoute()
const divRef = ref()
const editor = ref(null)
const routeName = ref('')
const title = ref('')

onMounted(() => {
  if(route.query && route.query.routeName) {
    routeName.value = route.query.routeName
    title.value = route.query.title
  }
  getHelp()
})
onUnmounted(() => {
  // editor.value && editor.value.destroy()
})
const getHelp = () => {
  tool.post('sets/getHelpById', {routeName: routeName.value}).then(ret => {
    if(ret.stat) {
      // editor.value = new AiEditor({
      //   element: divRef.value,
      //   placeholder: "点击输入内容...",
      //   content: ret.data,
      // })
    }
  })
}
const saveHelp = () => {
  // let cont = editor.value.getHtml()
  // if(routeName.value) {
  //   tool.post('sets/saveHelp', {
  //     routeName: routeName.value,
  //     cont
  //   }).then(ret => {
  //     if (ret.stat) {
  //
  //     }
  //   })
  // }
}

</script>